from time import time

FILE = None
LOG_ON = True

def createFileLogger():
    filename = "log.txt"
    FILE = open(filename,"w")
    FILE.write("START")

    
def closeFileLogger():
    FILE.close()

def log(line):
    """ writes a line to stdout """
    if LOG_ON:
        #print "asdf"
        c_time = time()
        line = "INFO : " + str(c_time) + ": " + str(line) + "\n" 
        print line
        filename = "log.txt"
        FILE = open(filename,"a")    
        FILE.write(line)
        FILE.close()
    
def debug(line):
    """ writes a line to stdout """
    if LOG_ON:
        c_time = time()
        line = "DEBUG: " + str(c_time) + ": " + str(line) + "\n" 
        print line
        filename = "log.txt"
        FILE = open(filename,"a")    
        FILE.write(line)
        FILE.close()
    